#import "AlertViewEnginner.h"


static CAlertViewEnginner *iInstance=Nil;
@implementation CAlertViewEnginner


-init
{
	if(self=[super init])
	{
	
	}
	return self;
}

-(void)dealloc
{
	[super dealloc];
}

-(void)Alert:(NSString *)message
{
	UIAlertView *alertDialog = [[[UIAlertView alloc] initWithTitle:nil
											message:message
										   delegate:nil
								  cancelButtonTitle:@"确定"
								  otherButtonTitles:nil] autorelease];
	[alertDialog show];
}


- (void)showWaitingDialog:(NSString*) aText
{	
	_waitingDialog = [[UIAlertView alloc] initWithTitle:nil
												message:NSLocalizedString(aText, @"TitleCaptionWattingDialog") 
											   delegate:self
									  cancelButtonTitle:nil
									  otherButtonTitles:nil];
	_waitingDialog.cancelButtonIndex=0;
	iCtivityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
	iCtivityIndicator.hidesWhenStopped=YES;
    [iCtivityIndicator setCenter:CGPointMake (132.0f, 60.0f)];
    [iCtivityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhiteLarge];
    [iCtivityIndicator startAnimating];
	
	[_waitingDialog addSubview:iCtivityIndicator];
	[_waitingDialog show];
}

- (void)closeWaitingDialog
{
	[iCtivityIndicator stopAnimating];
	[iCtivityIndicator release];
	iCtivityIndicator=nil;
	[_waitingDialog dismissWithClickedButtonIndex:0 animated:NO];
	[_waitingDialog release];
	_waitingDialog = NULL;
}
+ (CAlertViewEnginner*)GetIntance
{
	
	@synchronized(self)
	{
		if(!iInstance)
		{
			iInstance=[[CAlertViewEnginner alloc] init];
		}
	}
	return iInstance;
}

+ (void)Destroy
{
	@synchronized(self)
	{
		if(iInstance)
		{
			[iInstance release];
		}
	}
}

@end
